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

Text looks bad in Windows 10 #875

Closed
adamsiembida opened this issue Jul 10, 2021 · 6 comments · May be fixed by JetBrains/skia-pack#21
Closed

Text looks bad in Windows 10 #875

adamsiembida opened this issue Jul 10, 2021 · 6 comments · May be fixed by JetBrains/skia-pack#21
Assignees
Labels

Comments

@adamsiembida
Copy link

Text seems to look poorly rendered in Windows 10. I opened the Code Viewer example and just immediately thought the text looks off. Maybe it's not applying subpixel anti-aliasing, but I'm really not sure. The text looks too sharp and kinda jagged.

image

And I don't think its only this example. Ever since I started testing Compose Desktop I thought the text just didn't look quite right.

@igordmn
Copy link
Collaborator

igordmn commented Jul 10, 2021

Text in Compose for Desktop is rendered without subpixel anti-aliasing for now. The issue is known and blocked by the issue in skia (another one)

P.S.

  1. Flutter has a similar issue

  2. UWP applications (and Start Menu) don't use subpixel anti-aliasing too:
    image
    There is an issue in WinUI

@adamsiembida
Copy link
Author

adamsiembida commented Jul 10, 2021

Thanks for that information, it's good that the cause is known! I feel like I'm always having this issue whenever a new multiplatform-framework targets windows. I remember similar issues when Electron was new, and Qt also has issues unless you manually mess with text rendering. I know that a lot of devs use Macs nowadays, but a majority of consumers are still using Windows as far as I am aware--especially in the scientific and engineering (my area) communities where desktop apps are still the primary means of doing work.

@akurasov akurasov added bug Something isn't working desktop skia labels Jul 20, 2021
@igordmn
Copy link
Collaborator

igordmn commented Aug 17, 2021

By the way, there is a way to draw a text with subpixel antialiasing, if we use Canvas directly:

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.window.singleWindowApplication
import org.jetbrains.skija.Color
import org.jetbrains.skija.Font
import org.jetbrains.skija.FontEdging
import org.jetbrains.skija.Paint
import org.jetbrains.skija.TextLine
import org.jetbrains.skija.Typeface

val font = Font(Typeface.makeDefault()).apply {
    edging = FontEdging.SUBPIXEL_ANTI_ALIAS
    size = 24f
}

fun main() = singleWindowApplication {
    Canvas(Modifier.fillMaxSize()) {
        drawIntoCanvas {
            it.nativeCanvas.drawTextLine(
                TextLine.make("Text", font),
                0f,
                -font.metrics.ascent,
                Paint().apply {
                    color = Color.makeRGB(0, 0, 0)
                }
            )
        }
    }
}

image

igordmn added a commit to JetBrains/skia-pack that referenced this issue Sep 2, 2022
Fixes JetBrains/compose-multiplatform#875

TODO: read clear type settings on skiko level from system. The same way as Chromium does it:
https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/font_render_params_win.cc;l=91;drc=2d80b7b69c11da0716326b7fdc15568fc30820c2

Also we need to observe changes, and recreate surface in Skiko when pixel geometry changes (it happens, when the user rotates the display/tablet)
@adamsiembida
Copy link
Author

Thanks, this is huge 🎉 It basically opens up Compose Desktop for use on Windows!

@igordmn
Copy link
Collaborator

igordmn commented Oct 5, 2022

igordmn closed this as completed in JetBrains/skia-pack@05623f7 on Sep 2

It seems GitHub closed it somehow, even it is not merged yet.

It wasn't meant to be closed, so reopening, until we merge all functionality (it won't be in 1.2.0)

@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants