124
124
/* nameid :: The name id of the name record to return. */
127
/* name :: The address of a string pointer. NULL if no name is */
127
/* Character string. NULL if no name is present. */
131
/* FreeType error code. 0 means success. */
130
tt_face_get_name( TT_Face face,
134
tt_face_get_name( TT_Face face,
133
138
FT_Memory memory = face->root.memory;
139
FT_Error error = SFNT_Err_Ok;
134
140
FT_String* result = NULL;
136
142
TT_NameEntryRec* rec;
661
682
face->os2.version = 0xFFFFU;
666
686
/* the optional tables */
668
/* embedded bitmap support. */
688
/* embedded bitmap support */
669
689
if ( sfnt->load_eblc )
674
/* return an error if this font file has no outlines */
675
if ( error == SFNT_Err_Table_Missing && has_outline )
694
/* a font which contains neither bitmaps nor outlines is */
695
/* still valid (although rather useless in most cases); */
696
/* however, you can find such stripped fonts in PDFs */
697
if ( error == SFNT_Err_Table_Missing )
676
698
error = SFNT_Err_Ok;
697
717
face->root.num_glyphs = face->max_profile.numGlyphs;
700
719
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
701
720
/* a WWS-only font face. `WWS' stands for `weight', width', and */
702
721
/* `slope', a term used by Microsoft's Windows Presentation */
703
/* Foundation (WPF). This flag will be introduced in version */
704
/* 1.5 of the OpenType specification (but is already in use). */
722
/* Foundation (WPF). This flag has been introduced in version */
723
/* 1.5 of the OpenType specification (May 2008). */
706
725
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
709
face->root.family_name =
710
tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY );
727
GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
711
728
if ( !face->root.family_name )
712
face->root.family_name =
713
tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY );
729
GET_NAME( FONT_FAMILY, &face->root.family_name );
715
face->root.style_name =
716
tt_face_get_name( face, TT_NAME_ID_PREFERRED_SUBFAMILY );
731
GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
717
732
if ( !face->root.style_name )
718
face->root.style_name =
719
tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY );
733
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
724
/* Support for `name' table ID 21 (WWS family) and 22 (WWS */
725
/* subfamily) is still under consideration by Microsoft and */
726
/* not implemented in the current version of WPF. */
728
face->root.family_name =
729
tt_face_get_name( face, TT_NAME_ID_WWS_FAMILY );
730
if ( !face->root.family_name )
731
face->root.family_name =
732
tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY );
733
if ( !face->root.family_name )
734
face->root.family_name =
735
tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY );
737
face->root.style_name =
738
tt_face_get_name( face, TT_NAME_ID_WWS_SUBFAMILY );
739
if ( !face->root.style_name )
740
face->root.style_name =
741
tt_face_get_name( face, TT_NAME_ID_PREFERRED_SUBFAMILY );
742
if ( !face->root.style_name )
743
face->root.style_name =
744
tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY );
737
GET_NAME( WWS_FAMILY, &face->root.family_name );
738
if ( !face->root.family_name )
739
GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
740
if ( !face->root.family_name )
741
GET_NAME( FONT_FAMILY, &face->root.family_name );
743
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
744
if ( !face->root.style_name )
745
GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
746
if ( !face->root.style_name )
747
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
749
750
/* now set up root fields */
802
803
if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
804
/* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
805
/* indicates an oblique font face. This flag will be */
806
/* introduced in version 1.5 of the OpenType specification (but */
807
/* is already in use). */
805
/* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
806
/* indicates an oblique font face. This flag has been */
807
/* introduced in version 1.5 of the OpenType specification. */
809
809
if ( face->os2.fsSelection & 512 ) /* bit 9 */
810
810
flags |= FT_STYLE_FLAG_ITALIC;
865
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
868
* Now allocate the root array of FT_Bitmap_Size records and
869
* populate them. Unfortunately, it isn't possible to indicate bit
870
* depths in the FT_Bitmap_Size record. This is a design error.
876
#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
877
count = face->sbit_num_strikes;
879
count = (FT_UInt)face->num_sbit_strikes;
884
FT_Memory memory = face->root.stream->memory;
885
FT_UShort em_size = face->header.Units_Per_EM;
886
FT_Short avgwidth = face->os2.xAvgCharWidth;
887
FT_Size_Metrics metrics;
890
if ( em_size == 0 || face->os2.version == 0xFFFFU )
896
if ( FT_NEW_ARRAY( root->available_sizes, count ) )
899
for ( i = 0; i < count; i++ )
901
FT_Bitmap_Size* bsize = root->available_sizes + i;
904
error = sfnt->load_strike_metrics( face, i, &metrics );
908
bsize->height = (FT_Short)( metrics.height >> 6 );
909
bsize->width = (FT_Short)(
910
( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
912
bsize->x_ppem = metrics.x_ppem << 6;
913
bsize->y_ppem = metrics.y_ppem << 6;
916
bsize->size = metrics.y_ppem << 6;
919
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
920
root->num_fixed_sizes = (FT_Int)count;
924
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
926
/* a font with no bitmaps and no outlines is scalable; */
927
/* it has only empty glyphs then */
928
if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
929
root->face_flags |= FT_FACE_FLAG_SCALABLE;
865
932
/*********************************************************************/
867
934
/* Set up metrics. */
869
if ( has_outline == TRUE )
936
if ( FT_IS_SCALABLE( root ) )
871
938
/* XXX What about if outline header is missing */
872
939
/* (e.g. sfnt wrapped bitmap)? */
937
1003
if ( height > root->height )
938
1004
root->height = height;
943
root->max_advance_width = face->horizontal.advance_Width_Max;
945
root->max_advance_height = (FT_Short)( face->vertical_info
946
? face->vertical.advance_Height_Max
949
root->underline_position = face->postscript.underlinePosition;
1008
root->max_advance_width = face->horizontal.advance_Width_Max;
1009
root->max_advance_height = (FT_Short)( face->vertical_info
1010
? face->vertical.advance_Height_Max
1013
/* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
1014
/* Adjust underline position from top edge to centre of */
1015
/* stroke to convert TrueType meaning to FreeType meaning. */
1016
root->underline_position = face->postscript.underlinePosition -
1017
face->postscript.underlineThickness / 2;
950
1018
root->underline_thickness = face->postscript.underlineThickness;
953
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
956
* Now allocate the root array of FT_Bitmap_Size records and
957
* populate them. Unfortunately, it isn't possible to indicate bit
958
* depths in the FT_Bitmap_Size record. This is a design error.
964
#if !defined FT_CONFIG_OPTION_OLD_INTERNALS
965
count = face->sbit_num_strikes;
967
count = (FT_UInt)face->num_sbit_strikes;
972
FT_Memory memory = face->root.stream->memory;
973
FT_UShort em_size = face->header.Units_Per_EM;
974
FT_Short avgwidth = face->os2.xAvgCharWidth;
975
FT_Size_Metrics metrics;
978
if ( em_size == 0 || face->os2.version == 0xFFFFU )
984
if ( FT_NEW_ARRAY( root->available_sizes, count ) )
987
for ( i = 0; i < count; i++ )
989
FT_Bitmap_Size* bsize = root->available_sizes + i;
992
error = sfnt->load_strike_metrics( face, i, &metrics );
996
bsize->height = (FT_Short)( metrics.height >> 6 );
997
bsize->width = (FT_Short)(
998
( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
1000
bsize->x_ppem = metrics.x_ppem << 6;
1001
bsize->y_ppem = metrics.y_ppem << 6;
1004
bsize->size = metrics.y_ppem << 6;
1007
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
1008
root->num_fixed_sizes = (FT_Int)count;
1012
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */