From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by sourceware.org (Postfix) with ESMTPS id 49ED8388551F for ; Wed, 26 Oct 2022 20:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 49ED8388551F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-xe29.google.com with SMTP id s28so15675596vsr.10 for ; Wed, 26 Oct 2022 13:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=TqDRCIEVYvUtsmgHI9+jxE94Qt+hFFsrOO4w0kt9ubc=; b=D7MTaHVFERgN2tEfTZad71TKaapnN9iPCeFvYUoFHM1HzaEdOb28WbSLNQWjWObmc6 X1PTATfF/PlYrM3MCbZnGSo1UWkXaLqFudqLNQ8VHaHOgvP5aF6rDOY89wlEV7gX23Eq x6ZW4Ad3HyB5wsv3h9vnLmIv2+8GO+vl8FIQlo5yBNbOJ/08+lVJ1PRkUq6Wv7FwtN77 zYrPQCBW8YXIWzut+rti5EfWSGBy22j1notfVGE26OhWLDUg5H/dAoX9MIsu5+j+LFZw fBNHev3pE57sfs8LDtdmLtDfi/EsvXPFkIYH5rfugX2znaOaCEoqzJOlvL2y1EuvcSvV dzrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TqDRCIEVYvUtsmgHI9+jxE94Qt+hFFsrOO4w0kt9ubc=; b=DL8mt0Ef0RE6HaaVagm3nwXnatwsbZqne2Qg11O1pZCpMeNArPEEQdqS3LXs/MC22w 1YFBWlH2w2RIlylEtP6IEzuTSH39wew8cwncy1PfnSMcdui3chB1w+NJQhSCW7avDzxS SKKQ+fWizSax4z6uO0lH2bY6K1SATJqlLhSMcYfbMrycOpiWb76AnNqmui6PtdHkbOU3 npl+GSXx/5r9TXX7QB6LsraiGwHagALHHfhnx/DDrw+zzZa5RyZFF87/vjmyTwQ8NJ+F fDYkp0QRWsqVtY4yU0qz3Sm9z+wpbn8+c7E8e+TTRoH17tEpRzX0Qs9ocNoDI7SrEXch v42w== X-Gm-Message-State: ACrzQf3IW/t++mf3K7c7kjjmMQYY2AWrHX6jHKdpFv+lsSM+jcmbgVgJ gNQ7YYu49Ga4t860qqeRKDB2Z5TPAlQAYw612qD3YOfR X-Google-Smtp-Source: AMsMyM4B0cphY3cO6l53iQ91Sl96WO730i6/c5vFNySdgxEBZNdc7bMdwqspEEZyUMLtDSCdNihvnxn2HsGTnLd6uK4= X-Received: by 2002:a67:a246:0:b0:398:a4f4:aed1 with SMTP id t6-20020a67a246000000b00398a4f4aed1mr26435025vsh.6.1666817201582; Wed, 26 Oct 2022 13:46:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Panicz Maciej Godek Date: Wed, 26 Oct 2022 22:46:30 +0200 Message-ID: Subject: Re: Problem reading font data. To: Arvydas Silanskas , kawa@sourceware.org Content-Type: multipart/alternative; boundary="00000000000034b7f605ebf61f23" X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --00000000000034b7f605ebf61f23 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =C5=9Br., 26 pa=C5=BA 2022, 22:36 u=C5=BCytkownik Arvydas Silanskas < nma.arvydas.silanskas@gmail.com> napisa=C5=82: > Good day, > > I assume you lose the implicit classpath reference to working dir when you > launch with java. Does it work if you add it back explicitly, ie > > java -cp /path/to/kawa.jar:. kawa.repl -f font-test.scm > Yes, this helped. Thanks a lot! > Not sure what are the plans for distribution, but perhaps you might want > to load it from a file system instead of classpath. > Currently I have two ways of running my program: either by directly running the .scm file, or by building a .jar file. The latter is preferable, because it takes much less time. And the bundle also includes fonts. I'm also building an Android client, which virtually needs to use fonts from the bundle, because accessing the filesystem is problematic there. Thanks again! > Arvydas > > > 2022-10-26, tr, 23:23 Panicz Maciej Godek via Kawa > ra=C5=A1=C4=97: > >> I have the following code (it doesn't require graphics environment to >> run): >> >> (define-alias Font java.awt.Font) >> (define-alias InputStream java.io.InputStream) >> (define ClassLoader ::java.lang.ClassLoader >> (java.lang.ClassLoader:getSystemClassLoader)) >> >> (define the-graphics-environment >> ::parameter[java.awt.GraphicsEnvironment] >> (make-parameter >> (invoke-static >> java.awt.GraphicsEnvironment >> 'getLocalGraphicsEnvironment))) >> (define (load-font path::String #!key >> (size ::float 12.0)) >> (let* ((font-source ::InputStream >> (ClassLoader:getResourceAsStream path)) >> (font ::Font (Font:createFont >> Font:TRUETYPE_FONT >> font-source))) (invoke >> (the-graphics-environment) >> 'registerFont >> font) >> (font:deriveFont size))) >> >> (define-constant Basic-Regular >> (load-font "assets/Basic-Regular.otf" size: 20) >> >> The Basic-Regular.orf file is present in the assets directory, located in >> the same directory as the above file (that I called font-test.scm. >> >> When I run the code with >> >> $ kawa -f font-test.scm >> >> it behaves well. But when I instead use >> >> $ java -jar /path/to/kawa.jar -f font-test.scm >> >> or >> >> $ java -cp /path/to/kawa.jar kawa.repl -f font-test.scm >> >> I get the following error: >> >> java.io.IOException: Problem reading font data. at >> java.desktop/java.awt.Font.createFont0(Font.java:1208) >> at >> java.desktop/java.awt.Font.createFont(Font.java:1076) >> at >> atInteractiveLevel$Mn8.loadFont$check(font-test.scm:21) >> at >> gnu.mapping.CallContext.runUntilValue(CallContext.java:656) >> at >> atInteractiveLevel$Mn9.run(font-test.scm:27) at >> gnu.expr.ModuleExp.evalModule2(ModuleExp.java:290) at >> kawa.Shell.run(Shell.java:300) at >> kawa.Shell.runFile(Shell.java:562) at >> kawa.Shell.runFileOrClass(Shell.java:485) at >> kawa.repl.processArgs(repl.java:298) at >> kawa.repl.main(repl.java:830) >> >> I even went so far to modify the `which kawa` script by inserting "set -= x" >> in the first line following the she-bang: >> >> + KAWALIB=3D/data/data/com.termux/files/home/usr/share/kawa/lib/kawa.jar >> + >> >> CLASSPATH=3D/data/data/com.termux/files/home/usr/share/kawa/lib/kawa.jar= :/data/data/com.termux/files/usr/share/java/android.jar: >> + export CLASSPA= TH >> + test -n >> /data/data/com.termux/files/usr/opt/openjdk + >> JAVA=3D/data/data/com.termux/files/usr/opt/openjdk/bin/java + JVM_FLAG= S=3D >> + exec >> /data/data/com.termux/files/usr/opt/openjdk/bin/java >> -Dkawa.command.line=3D/data/data/com.termux/files/home/usr/bin/kawa -f >> font-test.scm -Dkawa.command.pid=3D20316 >> -Dkawa.home=3D/data/data/com.termux/files/home/usr/share/kawa kawa.repl = -f >> font-test.scm >> >> >> So - in orded to minimize the differences, I typed the following >> incantation: >> >> $ KAWALIB=3D/data/data/com.termux/files/home/usr/share/kawa/lib/kawa.jar >> CLASSPATH=3D/data/data/com.termux/files/home/usr/share/kawa/lib/kawa.jar >> /data/data/com.termux/files/usr/opt/openjdk/bin/java >> -Dkawa.command.line=3D"/data/data/com.termux/files/home/usr/bin/kawa -f >> font-test.scm" >> -Dkawa.home=3D/data/data/com.termux/files/home/usr/share/kawa >> kawa.repl -f font-test.scm >> >> But that still doesn't work. >> Does anyone know what could be the difference between these two runtime >> environments? >> >> (I checked, and they both report the same value of (current-path)) >> > --00000000000034b7f605ebf61f23--