Hi everyone, I’m building a Kotlin Multiplatform ...
# multiplatform
b
Hi everyone, I’m building a Kotlin Multiplatform Desktop application for editable label design and PDF import. I’m using Apache PDFBox to extract text, images, and vector shapes from PDF files and convert them into editable Compose elements. The main issue I’m facing is font recognition and rendering. Some PDFs import correctly, but others-especially PDFs exported from CorelDRAW—show incorrect fonts, fallback fonts, or square boxes instead of the original text style. Current setup: • Kotlin Multiplatform Desktop • Compose Multiplatform • Apache PDFBox • System fonts loaded through GraphicsEnvironment • Text extracted using PDFTextStripper/TextPosition What I want: • Detect the original font family from the PDF • Remove subset prefixes like
ABCDEE+ArialMT
• Map embedded/subset PDF fonts to the closest installed Windows font • Render the extracted text in Compose using that mapped font • Preserve bold, italic, size, color, rotation, and position The text content is usually extracted correctly, but the visual font does not match the original PDF. Has anyone implemented reliable PDF font mapping or system-font rendering in Compose Desktop? I’d especially appreciate guidance on: • Handling embedded or subsetted fonts • Mapping PDF font names to installed Windows fonts • Using system font families dynamically in Compose Desktop • Whether extracting embedded fonts from PDF is practical or legally safe • Better alternatives to PDFBox for this use case Any sample code, architecture suggestions, or library recommendations would be very helpful. Thank you.