Skip to content

Commit

Permalink
feat: add font and font_description.
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Oct 7, 2024
1 parent 5c1553f commit 4ad38d3
Show file tree
Hide file tree
Showing 10 changed files with 1,090 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@ if ($ENV{WEBF_JS_ENGINE} MATCHES "quickjs")
core/platform/gfx/geometry/rect_conversions.cc
core/platform/gfx/geometry/size_conversions.cc
core/platform/fonts/font_family.cc
core/platform/fonts/font_selection_types.cc
core/platform/fonts/font.cc

)

Expand Down
2 changes: 2 additions & 0 deletions bridge/core/css/css_to_length_conversion_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define WEBF_CORE_CSS_CSS_TO_LENGTH_CONVERSION_DATA_H_

#include "core/css/css_length_resolver.h"
#include "core/platform/fonts/font.h"
#include "core/style/font_size_style.h"

#include <optional>

Expand Down
37 changes: 37 additions & 0 deletions bridge/core/platform/fonts/font.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
* Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
* Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/

#include "font.h"

namespace webf {

Font::Font() = default;

bool Font::operator==(const Font& other) const {
return font_description_ == other.font_description_;
}

Font::Font(const FontDescription& fd) : font_description_(fd) {}

}
60 changes: 60 additions & 0 deletions bridge/core/platform/fonts/font.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
* Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Holger Hans Peter Freyther
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/

#ifndef WEBF_CORE_PLATFORM_FONTS_FONT_H_
#define WEBF_CORE_PLATFORM_FONTS_FONT_H_

#include "foundation/macros.h"
#include "core/platform/fonts/font_description.h"

namespace webf {

class GCVisitor;

class Font {
WEBF_DISALLOW_NEW();

public:
Font();
explicit Font(const FontDescription&);

Font(const Font&) = default;
Font(Font&&) = default;
Font& operator=(const Font&) = default;
Font& operator=(Font&&) = default;

bool operator==(const Font& other) const;
bool operator!=(const Font& other) const { return !(*this == other); }

const FontDescription& GetFontDescription() const {
return font_description_;
}

public:
FontDescription font_description_;
};

}

#endif // WEBF_CORE_PLATFORM_FONTS_FONT_H_
26 changes: 26 additions & 0 deletions bridge/core/platform/fonts/font_description.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights
* reserved.
* Copyright (C) 2007 Nicholas Shanks <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/

#include "font_description.h"
Loading

0 comments on commit 4ad38d3

Please sign in to comment.