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

Unable to load AP-OTF fonts (DecodingError NotARealInDict) #61

Closed
ghaaj opened this issue Nov 6, 2024 · 5 comments · Fixed by #62
Closed

Unable to load AP-OTF fonts (DecodingError NotARealInDict) #61

ghaaj opened this issue Nov 6, 2024 · 5 comments · Fixed by #62

Comments

@ghaaj
Copy link

ghaaj commented Nov 6, 2024

Environment: WSL2 Ubuntu 24.04

When trying to load Morisawa's AP-OTF-*.otf fonts, otfedcli throws the following error:

$ dune exec otfedcli ~/.satysfi/dist/fonts/MorisawaFonts/AP-OTF-RyuminPr6N-Regular.otf tables
(DecodingError NotARealInDict)

~/.satysfi/dist/fonts/MorisawaFonts is a symlink to %LOCALAPPDATA%\Microsoft\Windows\Fonts\MorisawaFonts in the mounted Windows file system.

Given the contents of dictmap, it appears that this error is thrown in get_real_with_default due to the value for LongKey(31) being [Integer(1)].

otfed/src/decodeCff.ml

Lines 62 to 67 in c11304c

let get_real_with_default dictmap key default =
let open ResultMonad in
match DictMap.find_opt key dictmap with
| Some(Real(r) :: []) -> return r
| Some(_) -> err Error.NotARealInDict
| None -> return default

I'm not sure why cid_font_version needs to be a float. From reading the spec it seems to me that CIDFontVersion is defined as an integer. Page 22 of the document says:

The %%Version comment provides the version number of this CIDFont file.
This number is an integer; Adobe recommends that it be the same number that is defined for /CIDFontVersion later in the file.
%%Version: 1

Please note that I'm a layman in terms of typography. Thank you.

@gfngfn
Copy link
Owner

gfngfn commented Nov 6, 2024

Thank you for the report! This is a great catch.

The referenced spec is actually “Technical Note #5176: The Compact Font Format Specification, Version 1.0”.

I haven't encountered that error so far, but it seems that this was by chance; according to Table 10 on page 16, CIDFontVersion must be a number, i.e., it can be an integer as well as a (decimally encoded) real number:

Table 10 of Technical Note #5176: The Compact Font Format Specification, Version 1.0

I should thereby fix this so that otfed can decode versions encoded as integers.

@gfngfn
Copy link
Owner

gfngfn commented Nov 6, 2024

Side note: I can access RyuminPr6N-Light via Adobe CC, so I checked the CIDFontVersion of the font file. It was 1.2:

$ otfedcli 26143.otf cff_top 
CFF Top DICT:
  { font_name = "RyuminPr6N-Light"; version = None;
    notice =
    (Some "(c) Copyright 1989-2007 Adobe Systems Incorporated. All rights reserved. Ryumin Light is a trademark of Morisawa Inc.");
    copyright =
    (Some "Font (c) Copyright 2007 Morisawa Inc. All rights reserved.");
    full_name = (Some "Ryumin Pr6N OpenType Light");
    family_name = (Some "Ryumin Pr6N OpenType"); weight = (Some "Light");
    is_fixed_pitch = false; italic_angle = 0; underline_position = -100;
    underline_thickness = 50; paint_type = 0;
    font_bbox = { x_min = -280; y_min = -294; x_max = 1134; y_max = 1160 };
    stroke_width = 0;
    cid_info =
    (Some { registry = "Adobe"; ordering = "Japan1"; supplement = 6;
            cid_font_version = 1.2; cid_font_revision = 0; cid_font_type = 0;
            cid_count = 23058 });
    number_of_glyphs = 23058 }

@gfngfn
Copy link
Owner

gfngfn commented Nov 6, 2024

The PR #62 will remedy this issue. Thank you!

@gfngfn gfngfn closed this as completed in #62 Nov 6, 2024
@gfngfn
Copy link
Owner

gfngfn commented Nov 7, 2024

I've reflected the change above in the master branch of SATySFi: gfngfn/SATySFi#466

@ghaaj
Copy link
Author

ghaaj commented Nov 7, 2024

Thank you for your prompt action!

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

Successfully merging a pull request may close this issue.

2 participants