Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get specific platform name entry #73

Open
guidoferreyra opened this issue Oct 9, 2019 · 5 comments
Open

Get specific platform name entry #73

guidoferreyra opened this issue Oct 9, 2019 · 5 comments
Milestone

Comments

@guidoferreyra
Copy link

Hi! I want to get the string associated with the Mac Entry id 2?

I tried different things but I dont get it.

getNameTableString() only returns Win entries?

@bsweeney
Copy link
Member

If you're still interested in this can you clarify what you want to retrieve?

@lslqtz
Copy link

lslqtz commented Feb 11, 2024

I just discovered this problem. By modifying it and adding other key information, I got what I needed.

I've modified these functions below so that you can get a more specific message and use your own judgment to suit your needs. This change improves flexibility, but also increases the complexity for users.

In addition, I also tried to support automatic encoding detection under mac fonts.

lslqtz@cc1a5a8

The most common combinations tend to be the following:

Mac (1,0,0,1) Font Family: FZLanTingYuan-DB-GBK
Mac (1,0,0,2) Font Subfamily: Regular
Mac (1,0,0,3) Unique Identifier: Founder:FZLanTingYuan-DB-GBK	Regular
Mac (1,0,0,4) Full Name: FZLanTingYuan-DB-GBK
Mac (1,0,0,5) Version: 1.00
Mac (1,0,0,6) PostScript Name: FZLANTY_ZHONGK--GBK1-0

Microsoft (3,1,1033,1) Font Family: FZLanTingYuan-DB-GBK
Microsoft (3,1,1033,2) Font Subfamily: Regular
Microsoft (3,1,1033,3) Unique Identifier: Founder:FZLanTingYuan-DB-GBK	Regular
Microsoft (3,1,1033,4) Full Name: FZLanTingYuan-DB-GBK
Microsoft (3,1,1033,5) Version: 1.00

2052: Language ID
Microsoft (3,1,1033,6) PostScript Name: FZLANTY_ZHONGK--GBK1-0
Microsoft (3,1,2052,1) Font Family: 方正兰亭圆_GBK_中
Microsoft (3,1,2052,2) Font Subfamily: Regular
Microsoft (3,1,2052,3) Unique Identifier: Founder:方正兰亭圆_GBK_中	Regular
Microsoft (3,1,2052,4) Full Name: 方正兰亭圆_GBK_中

(BTW: https://github.com/ConradIrwin/font is a good program. Its info tool can list the raw data in detail, which is helpful for your debugging.)

Specifically:

  ["3,1,1033,4"]=>
  object(FontLib\Table\Type\nameRecord)#43 (9) {
    ["f":protected]=>
    NULL
    ["platformID"]=>
    int(3)
    ["platformSpecificID"]=>
    int(1)
    ["languageID"]=>
    int(1033)
    ["nameID"]=>
    int(4)
    ["length"]=>
    int(40)
    ["offset"]=>
    int(675)
    ["string"]=>
    string(20) "FZLanTingYuan-DB-GBK"
    ["stringRaw"]=>
    string(40) "FZLanTingYuan-DB-GBK"
  }

If I don't modify it, it just discards/overwrites this information.

function getFontCopyright($platformID, $platformSpecificID, $languageID)
function getFontName($platformID, $platformSpecificID, $languageID)
function getFontSubfamily($platformID, $platformSpecificID, $languageID)
function getFontSubfamilyID($platformID, $platformSpecificID, $languageID)
function getFontFullName($platformID, $platformSpecificID, $languageID)
function getFontVersion($platformID, $platformSpecificID, $languageID)
function getFontPostscriptName($platformID, $platformSpecificID, $languageID)

Usage like this:

				if ($font->getFontName(3,1,2052) !== null) {
					$fontsInfoArr[] = [$font->getFontName(3,1,2052), $font->getFontFullName(3,1,2052), $font->getFontPostscriptName(3,1,2052), $font->getFontSubfamily(3,1,2052)];
				}
				if ($font->getFontName(3,1,1033) !== null) {
					$fontsInfoArr[] = [$font->getFontName(3,1,1033), $font->getFontFullName(3,1,1033), $font->getFontPostscriptName(3,1,1033), $font->getFontSubfamily(3,1,1033)];
				}

@bsweeney bsweeney reopened this Feb 11, 2024
@bsweeney bsweeney added this to the 1.1.0 milestone Feb 11, 2024
@bsweeney
Copy link
Member

@lslqtz feel free to submit a PR with those changes. Happy to review and include in a future release.

@lslqtz
Copy link

lslqtz commented Feb 12, 2024

@lslqtz feel free to submit a PR with those changes. Happy to review and include in a future release.

I'm using a very simple modification, so I'm not sure I can guarantee its backwards compatibility, especially since I don't fully analyze and understand its replacement behavior. But this modification did solve my problem, so I posted these usages and cases in issues that may be similar.

Since these new parameters are required in my modification, it may become a breaking change.

(Another problem is that I only modified the TrueType function, which may lead to inconsistent usage between different font type)

@bsweeney
Copy link
Member

Thank you for the follow up. I'll review your changes and see how we can adapt them.

Also, if you have any sample fonts for testing that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants