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

support for css rem #1265

Open
Mamong opened this issue Feb 27, 2023 · 2 comments
Open

support for css rem #1265

Mamong opened this issue Feb 27, 2023 · 2 comments

Comments

@Mamong
Copy link

Mamong commented Feb 27, 2023

in "NSCharacterSet+HTML.h"
replace
_cssLengthUnitCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"pxtem"];
to
_cssLengthUnitCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"pxtrem"];

in "NSString+CSS.h"
replace
if ([numberUnitStr isEqualToString:@"em"] | [numberUnitStr isEqualToString:@"px"] | [numberUnitStr isEqualToString:@"pt"])
to
if ([numberUnitStr isEqualToString:@"em"] | [numberUnitStr isEqualToString:@"px"] | [numberUnitStr isEqualToString:@"pt"] | [numberUnitStr isEqualToString:@"rem"])

add below

    else if (ch == 'r') {
        // rem
        if (i<stringLength)
        {
            if (_characters[i++] == 'e')
            {
                if (i<stringLength)
                {
                    if (_characters[i++] == 'm')
                    {
                        // rem value
                       //  this is just a workaround. FIXME: rem should be calculated as  'value *=  root element font-size'
                        value *= textSize;
                    }
                 }
            }
        }
    }
  else if (ch == 'e')
@odrobnik
Copy link
Collaborator

That only allows it to parse but you are missing the conversion to points. Please send a change request with you changes/additions

@Mamong
Copy link
Author

Mamong commented Feb 27, 2023

@odrobnik Hi, I'm writting an epub reader, then I run into a problem with one epub file. The font size of some content is just 1.00pt. I find the problem is that DTCoreText does not parse rem correctly. I fix it with my patch as above. But, I dont know how to get the 'root element' font-size. According to the defination, rem should be calculated as 'value *= root element font-size'. As a workaround, I just make it works like an em.

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

No branches or pull requests

2 participants