Skip to content

Commit

Permalink
Merge pull request #194 from HinTak/FT_ENCODING_fix
Browse files Browse the repository at this point in the history
Ft encoding fix
  • Loading branch information
HinTak authored May 17, 2024
2 parents a3f915b + c3e399a commit 277a55b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/ft_encodings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions doc/tt_ms_ids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions examples/font-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

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))
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))
Expand Down
16 changes: 8 additions & 8 deletions examples/ftdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ):
Expand Down Expand Up @@ -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 ):
Expand Down
9 changes: 5 additions & 4 deletions freetype/ft_enums/ft_encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' ),
Expand Down
9 changes: 5 additions & 4 deletions freetype/ft_enums/tt_ms_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 277a55b

Please sign in to comment.