From 1cd65f457ee4f0c8c51d99f19ec0e4a665f3020f Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 22:55:37 +0100 Subject: [PATCH 1/5] enum FT_ENCODING_GB2312 was renamed FT_ENCODING_PRC upstream in 2017 fixes #192 Upstream: commit 464b16ba46c5ce44aa0dae2e67fefe7c2abbd7f1 Author: Werner Lemberg Date: Fri Jan 27 08:45:46 2017 +0100 s/GB2312/PRC/. * include/freetype/freetype.h (FT_ENCODING_PRC): New enum value. (FT_ENCODING_GB2312): Deprecated. * include/freetype/ttnameid.h (TT_MS_ID_PRC): New macro. (TT_MS_ID_GB2312): Deprecated. * src/sfnt/sfobjs.c (sfnt_find_encoding): Updated. * docs/CHANGES: Updated. --- doc/ft_encodings.rst | 2 +- doc/tt_ms_ids.rst | 4 ++-- freetype/ft_enums/ft_encodings.py | 9 +++++---- freetype/ft_enums/tt_ms_ids.py | 9 +++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/doc/ft_encodings.rst b/doc/ft_encodings.rst index fc53e308..6e9ea795 100644 --- a/doc/ft_encodings.rst +++ b/doc/ft_encodings.rst @@ -29,7 +29,7 @@ the FT_Select_Charmap API function. 'http://langsupport.japanreference.com/encoding.shtml'. See note on multi-byte encodings below. -.. data:: FT_ENCODING_GB2312 +.. data:: FT_ENCODING_PRC Corresponds to an encoding system for Simplified Chinese as used used in mainland China. diff --git a/doc/tt_ms_ids.rst b/doc/tt_ms_ids.rst index ede063c6..b3065c36 100644 --- a/doc/tt_ms_ids.rst +++ b/doc/tt_ms_ids.rst @@ -21,10 +21,10 @@ charmaps and name entries. Corresponds to SJIS Japanese encoding. See FT_ENCODING_SJIS. -.. data:: TT_MS_ID_GB2312 +.. data:: TT_MS_ID_PRC Corresponds to Simplified Chinese as used in Mainland China. See - FT_ENCODING_GB2312. + FT_ENCODING_PRC. .. data:: TT_MS_ID_BIG_5 diff --git a/freetype/ft_enums/ft_encodings.py b/freetype/ft_enums/ft_encodings.py index 50f38de4..566bc375 100644 --- a/freetype/ft_enums/ft_encodings.py +++ b/freetype/ft_enums/ft_encodings.py @@ -34,10 +34,11 @@ 'http://langsupport.japanreference.com/encoding.shtml'. See note on multi-byte encodings below. -FT_ENCODING_GB2312 +FT_ENCODING_PRC - Corresponds to an encoding system for Simplified Chinese as used used in - mainland China. + Corresponds to encoding systems mainly for Simplified Chinese as + used in People's Republic of China (PRC). The encoding layout + is based on GB~2312 and its supersets GBK and GB~18030. FT_ENCODING_BIG5 @@ -94,7 +95,7 @@ def _FT_ENC_TAG(a,b,c,d): 'FT_ENCODING_MS_SYMBOL' : _FT_ENC_TAG( 's','y','m','b' ), 'FT_ENCODING_UNICODE' : _FT_ENC_TAG( 'u','n','i','c' ), 'FT_ENCODING_SJIS' : _FT_ENC_TAG( 's','j','i','s' ), - 'FT_ENCODING_GB2312' : _FT_ENC_TAG( 'g','b',' ',' ' ), + 'FT_ENCODING_PRC' : _FT_ENC_TAG( 'g','b',' ',' ' ), 'FT_ENCODING_BIG5' : _FT_ENC_TAG( 'b','i','g','5' ), 'FT_ENCODING_WANSUNG' : _FT_ENC_TAG( 'w','a','n','s' ), 'FT_ENCODING_JOHAB' : _FT_ENC_TAG( 'j','o','h','a' ), diff --git a/freetype/ft_enums/tt_ms_ids.py b/freetype/ft_enums/tt_ms_ids.py index 57027bb9..fa8daf71 100644 --- a/freetype/ft_enums/tt_ms_ids.py +++ b/freetype/ft_enums/tt_ms_ids.py @@ -26,10 +26,11 @@ Corresponds to SJIS Japanese encoding. See FT_ENCODING_SJIS. -TT_MS_ID_GB2312 +TT_MS_ID_PRC - Corresponds to Simplified Chinese as used in Mainland China. See - FT_ENCODING_GB2312. + Chinese encodings as used in the People's Republic of China (PRC). + This means the encodings GB~2312 and its supersets GBK and + GB~18030. See FT_ENCODING_PRC. TT_MS_ID_BIG_5 @@ -57,7 +58,7 @@ 'TT_MS_ID_SYMBOL_CS' : 0, 'TT_MS_ID_UNICODE_CS' : 1, 'TT_MS_ID_SJIS' : 2, - 'TT_MS_ID_GB2312' : 3, + 'TT_MS_ID_PRC' : 3, 'TT_MS_ID_BIG_5' : 4, 'TT_MS_ID_WANSUNG' : 5, 'TT_MS_ID_JOHAB' : 6, From 4d24cd491f7fe0598cad20ef4a92b49a5d1e7afb Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 23:11:31 +0100 Subject: [PATCH 2/5] Fixes cosmetic issue with python print(). Looked to be copied from C printf code --- examples/ftdump.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ftdump.py b/examples/ftdump.py index b676d099..9f6578cd 100644 --- a/examples/ftdump.py +++ b/examples/ftdump.py @@ -214,11 +214,11 @@ def Print_Fixed( face ): # available size for i,bsize in enumerate(face.available_sizes): - print( " %3d: height %d, width %d\n", - i, bsize.height, bsize.width ) - print( " size %.3f, x_ppem %.3f, y_ppem %.3f\n", - bsize.size / 64.0, - bsize.x_ppem / 64.0, bsize.y_ppem / 64.0 ) + print( " %3d: height %d, width %d" % + ( i, bsize.height, bsize.width ) ) + print( " size %.3f, x_ppem %.3f, y_ppem %.3f" % + ( bsize.size / 64.0, + bsize.x_ppem / 64.0, bsize.y_ppem / 64.0 ) ) def Print_Charmaps( face ): From 3af4d3e7ab8b06dd2489fc1a16ab2e3e9de89586 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 23:20:45 +0100 Subject: [PATCH 3/5] Overdued python 3 update to string-formatting in ftdump.py --- examples/ftdump.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/ftdump.py b/examples/ftdump.py index 9f6578cd..09137995 100644 --- a/examples/ftdump.py +++ b/examples/ftdump.py @@ -29,10 +29,10 @@ def usage( execname ): def Print_Name( face ): print( "font name entries" ); - print( " family: %s" % face.family_name ) - print( " style: %s" % face.style_name ) + print( " family: %s" % face.family_name.decode("ascii", errors='ignore') ) + print( " style: %s" % face.style_name.decode("ascii", errors='ignore') ) ps_name = face.postscript_name or "UNAVAILABLE" - print( " postscript: %s" % ps_name ) + print( " postscript: %s" % ps_name.decode("ascii", errors='ignore') ) def Print_Type( face ): From bd91bb45af84e109b28b31eeee38a96d6e675ddd Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 23:33:35 +0100 Subject: [PATCH 4/5] Cosmetic issue with listing Available sizes --- examples/font-info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/font-info.py b/examples/font-info.py index d362f875..b8236979 100644 --- a/examples/font-info.py +++ b/examples/font-info.py @@ -23,7 +23,8 @@ print ('') print ('Face number: {}'.format(face.num_faces)) print ('Glyph number: {}'.format(face.num_glyphs)) - print ('Available sizes: {}'.format(face.available_sizes)) + # FT_Bitmap_Size.size is in F26.6. Need to divide by 64: + print ('Available sizes: {}'.format([bitmap_size.size/64 for bitmap_size in face.available_sizes])) print ('') print ('units per em: {}'.format(face.units_per_EM)) print ('ascender: {}'.format(face.ascender)) From c3e399aca65149334fc12f7db9a62d146e112cfe Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Thu, 16 May 2024 23:35:42 +0100 Subject: [PATCH 5/5] Another overdued python 3 string-formatting, in font-info.py --- examples/font-info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/font-info.py b/examples/font-info.py index b8236979..73739167 100644 --- a/examples/font-info.py +++ b/examples/font-info.py @@ -17,8 +17,8 @@ face = Face(sys.argv[1]) - print ('Family name: {}'.format(face.family_name)) - print ('Style name: {}'.format(face.style_name)) + print ('Family name: {}'.format(face.family_name.decode("ascii", errors='ignore'))) + print ('Style name: {}'.format(face.style_name.decode("ascii", errors='ignore'))) print ('Charmaps: {}'.format([charmap.encoding_name for charmap in face.charmaps])) print ('') print ('Face number: {}'.format(face.num_faces))