bugThe FreeType Project - Bugs: bug #27987, Strip subset prefix when...

 
 

bug #27987: Strip subset prefix when generating family_name from font_name

Submitted by:  bram tassyns <bramt>
Submitted on:  Tue 10 Nov 2009 08:21:33 AM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: 2.3.13

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 21 May 2010 08:16:38 AM UTC, comment #6:

I've applied your patch. Please check.

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Fri 30 Apr 2010 07:06:11 PM UTC, comment #5:

http://lundestudio.com/CJKV2E/cjkv2e-pp448-450.pdf is an example of a pdf with embedded fonts which came from a SFNT/cff file.

MULOG=f mupdf cjkv2e-pp448-450.pdf

reports blocks like:

font: load simple font (79 0 R) ptr=0x86759c8 {
font: basefont0 XNORUC+MyriadPro-SemiboldCond
font: basefont1 XNORUC+MyriadPro-SemiboldCond
font: load fontdescriptor {
font: fontname 'XNORUC+MyriadPro-SemiboldCond'
font: bbox [-145 -250 970 948]
font: flags 32
font: load embedded font
font: }
font: ft font format CFF
font: ft name 'XNORUC+MyriadPro-SemiboldCond' 'Regular'
font: ft bbox [-145 -250 970 948]
font: encode type1/cff by strings
font: tounicode embedded cmap
font: load embedded cmap (53 0 R) {
font: }
font: }

If instead one looks at a pdf which embeds fonts which were type1 (this example, http://arxiv.org/pdf/0910.5226.pdf uses the type1 CM fonts), then the prefix is elided in the report:

font: load simple font (53 0 R) ptr=0x86f4600 {
font: basefont0 TELHPV+CMSY10
font: basefont1 TELHPV+CMSY10
font: load fontdescriptor {
font: fontname 'TELHPV+CMSY10'
font: bbox [0 -960 853 750]
font: flags 4
font: load embedded font
font: }
font: ft font format CFF
font: ft name 'CMSY10' 'Regular'
font: ft bbox [0 -960 853 750]
font: encode type1/cff by strings
font: tounicode strings
font: }

Note the difference in the »ft name« field.

I also looked at a file generated by ’zilla (using cairo git master) and DejaVu Serif, an SFNT/glyf font. Cairo embeds it as a CID with /Identity-H. No »ft name« field shows up at all:

font: load cid font (35 0 R) ptr=0x869fb88 {
font: basefont HVRYAW+DejaVuSerif
font: collection Adobe-Identity
font: load fontdescriptor {
font: fontname 'HVRYAW+DejaVuSerif'
font: bbox [-769 -346 1679 1242]
font: flags 4
font: load embedded font
font: }
font: ft font format TrueType
font: ft bbox [-769 -346 1679 1242]
font: encoding /Identity-H
font: wmode 0
font: tounicode embedded cmap
font: load embedded cmap (32 0 R) {
font: }
font: }

I’ll attach the cairo file, a printout of google’s 2010 April Fools homepage, Google-Topeka.pdf.

(file #20380)

James Cloos <cloos>
Fri 16 Apr 2010 08:33:01 AM UTC, comment #4:

Could you attach the font or pdf for which this isn't working ?

bram tassyns <bramt>
Sat 03 Apr 2010 06:22:36 PM UTC, comment #3:

Here is an example of this not working; it comes from a MUDBG=f trace of mupdf:

font: load simple font (2109 0 R) ptr=0x86f45c0 {
font: basefont0 NJZUAS+MyriadPro-Regular
font: basefont1 NJZUAS+MyriadPro-Regular
font: load fontdescriptor {
font: fontname 'NJZUAS+MyriadPro-Regular'
font: bbox [-157 -250 1126 952]
font: flags 32
font: load embedded font
font: }
font: ft font format CFF
font: ft name 'NJZUAS+MyriadPro-Regular' 'Regular'
font: ft bbox [-157 -250 1126 952]
font: encode type1/cff by strings
font: tounicode strings
font: }

Subset t1 fonts do not retain the prefix in the ft name reports; only cff fonts do.

As such, the cff fontname code may just need to be normalized with the type1 code.

James Cloos <cloos>
Tue 10 Nov 2009 02:36:03 PM UTC, comment #2:

So far I've only encountered one form of prefixes, don't know for sure if it's the only one though.

bram tassyns <bramt>
Tue 10 Nov 2009 02:34:39 PM UTC, comment #1:

Is the form of the prefix standardized? Otherwise this should be an option -- probably the default, but configurable IMHO.

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Tue 10 Nov 2009 08:21:33 AM UTC, original submission:

For cff fonts the family name is automaticly generated from the font_name. However for subsetted fonts this gives wierd results if you don't strip the subset prefix from the name before creating the family_name.

cffobj.c, 684:

...
if ( cffface->family_name )
{
char* full = cff_index_get_sid_string( &cff->string_index,
dict->full_name,
psnames );
char* fullp = full;
char* family = cffface->family_name;
char* family_name = 0;

if ( dict->family_name )
{
...
=>
...
if ( cffface->family_name )
{
char* full = cff_index_get_sid_string( &cff->string_index,
dict->full_name,
psnames );
char* fullp = full;
char* family = cffface->family_name;
char* family_name = 0;

remove_subset_prefix( cffface->family_name );
if ( dict->family_name )
{
...

with:

/* Strip all subset prefixes (usually only one, but I've seen fonts */
/* like "APCOOG+JFABTD+FuturaBQ-Bold" e.g. in prn 3029) */
static void
remove_subset_prefix( FT_String* name )
{
FT_Int32 index = 0;
FT_Int32 length = strlen( name ) + 1;
FT_Bool continue_search = 1;

while ( continue_search )
{
if( length >= 7 && name[6] == '+' )
{
for ( index = 0; index < 6; ++index)
{
if( ! ('A' <= name[index] && name[index] <= 'Z' ) )
continue_search = 0;
}
if ( continue_search )
{
for ( index = 7; index < length; ++index )
{
name[index-7] = name[index];
}
}
}
else
{
continue_search = 0;
}
}
}

bram tassyns <bramt>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #20380:  Google-Topeka.pdf added by cloos (32KiB - application/pdf)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by cloos (Posted a comment)
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by bramt (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 21 May 2010 08:16:38 AM UTCwlStatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.3.13
    Fri 30 Apr 2010 07:06:11 PM UTCcloosAttached File-=>Added Google-Topeka.pdf, #20380
    Tue 10 Nov 2009 02:34:39 PM UTCwlAssigned toNone=>wl
      StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1