Skip to content

Commit

Permalink
[Text] Add type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Aug 6, 2024
1 parent e4bb95c commit 6adc5ff
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
26 changes: 16 additions & 10 deletions src/Aardvark.Rendering.Text/Font.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ open System
open System.Collections.Concurrent
open System.Runtime.CompilerServices
open Aardvark.Base
open Aardvark.Base.Fonts
open Aardvark.Rendering
open Aardvark.FontProvider

type PathSegment = Aardvark.Base.Fonts.PathSegment
type Path = Aardvark.Base.Fonts.Path
type Shape = Aardvark.Base.Fonts.Shape
type Font = Aardvark.Base.Fonts.Font
type CodePoint = Aardvark.Base.Fonts.CodePoint
type Glyph = Aardvark.Base.Fonts.Glyph

module DefaultFonts =

/// https://www.fontsquirrel.com/fonts/hack
Expand Down Expand Up @@ -61,7 +67,7 @@ module DefaultFonts =
[<AutoOpen>]
module ShapeExtensions =

type Shape with
type Aardvark.Base.Fonts.Shape with
member x.IndexedGeometry =
IndexedGeometry(
Mode = IndexedGeometryMode.TriangleList,
Expand Down Expand Up @@ -245,20 +251,20 @@ type ShapeCache(r : IRuntime) =
type PrepareFontExtensions private() =

[<Extension>]
static member PrepareGlyphs(r : IRuntime, f : Font, chars : seq<CodePoint>) =
let cache = ShapeCache.GetOrCreateCache r
static member PrepareGlyphs(runtime: IRuntime, font: Font, chars: seq<CodePoint>) =
let cache = ShapeCache.GetOrCreateCache runtime

for c in chars do
cache.GetBufferRange (f.GetGlyph(c)) |> ignore
cache.GetBufferRange (font.GetGlyph(c)) |> ignore

[<Extension>]
static member PrepareGlyphs(r : IRuntime, f : Font, chars : seq<char>) =
let cache = ShapeCache.GetOrCreateCache r
static member PrepareGlyphs(runtime: IRuntime, font: Font, chars: seq<char>) =
let cache = ShapeCache.GetOrCreateCache runtime

for c in chars do
cache.GetBufferRange (f.GetGlyph(CodePoint c)) |> ignore
cache.GetBufferRange (font.GetGlyph(CodePoint c)) |> ignore

[<Extension>]
static member PrepareTextShaders(r : IRuntime, f : Font, signature : IFramebufferSignature) =
let cache = ShapeCache.GetOrCreateCache r
static member PrepareTextShaders(runtime: IRuntime, signature: IFramebufferSignature) =
let cache = ShapeCache.GetOrCreateCache runtime
cache.PrepareShaders signature
1 change: 0 additions & 1 deletion src/Aardvark.Rendering.Text/Markdown.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Aardvark.Rendering.Text


open Aardvark.Base
open Aardvark.Base.Fonts
open FSharp.Data.Adaptive
Expand Down
4 changes: 1 addition & 3 deletions src/Aardvark.Rendering.Text/SceneGraph.fs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
namespace Aardvark.Rendering.Text

open Aardvark.Base
open Aardvark.Base.Fonts

open FSharp.Data.Adaptive
open Aardvark.Rendering
open Aardvark.Rendering.Text
open Aardvark.SceneGraph
open Aardvark.SceneGraph.Semantics
open FSharp.Data.Adaptive
open FSharp.Data.Traceable

module RenderPass =
Expand Down
2 changes: 1 addition & 1 deletion src/Demo/Examples/GeometryComposition.fs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ module GeometryComposition =
let w = 1 + (ceil (sqrt (float combinations.Length)) |> int)
let h = ceil (float combinations.Length / float w) |> int

let font = Aardvark.Base.Fonts.Font("Consolas")
let font = Font("Consolas")

let u (n : String) (m : IAdaptiveValue) (s : ISg) =
Sg.UniformApplicator(n, m, s) :> ISg
Expand Down
1 change: 0 additions & 1 deletion src/Demo/Examples/Stereo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

open System
open Aardvark.Base
open Aardvark.Base.Fonts
open FSharp.Data.Adaptive

open Aardvark.SceneGraph
Expand Down
2 changes: 1 addition & 1 deletion src/Demo/Examples/Wobble.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module Wobble =
|> AVal.map (fun s -> Frustum.perspective 60.0 0.1 100.0 (float s.X / float s.Y))
|> AVal.map Frustum.projTrafo

let font = Aardvark.Base.Fonts.Font("Consolas")
let font = Font("Consolas")
let task =
Sg.ofList [
Sg.ofList [
Expand Down
2 changes: 1 addition & 1 deletion src/Examples (netcore)/33 - Opc/Overlay.fs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ module Overlay =
let bgAlpha = byte (255.0 * 0.6)
let config =
{ TextConfig.Default with
font = Aardvark.Base.Fonts.Font "Blackadder ITC"
font = Font "Blackadder ITC"
color = C4b(255uy, 255uy, 255uy, fgAlpha)
align = TextAlignment.Left
flipViewDependent = false
Expand Down
1 change: 0 additions & 1 deletion src/Scratch (netcore)/04 - ManyTexts/Program.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
open Aardvark.Base
open Aardvark.Base.Fonts
open Aardvark.Rendering
open FSharp.Data.Adaptive
open FSharp.Data.Adaptive.Operators
Expand Down

0 comments on commit 6adc5ff

Please sign in to comment.